<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>form view</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link href="../../bootstrap/css/bootstrap.css" rel="stylesheet">
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script> 
<script src="form-view-js.js"></script>
<link rel="stylesheet" type="text/css" href="form-vew-style.css">
<style>
.container{
	box-shadow: 10px 0px 10px -10px rgba(0,0,0,0.45), -10px 0px 10px -10px rgba(0,0,0,0.45);
}
#header-table{
	border:none;
}
#header-table tr td{
	border:none;
}
</style>
</head>

<body>
<!--<label for="from">From</label>
<input type="text" id="from" name="from">
<label for="to">to</label>
<input type="text" id="to" name="to"><br><br><br>-->
<div class="container" style="background-color:white;">
<h2 class="text-center">Final Verification Sheet (Business Loans)</h2>
<div class="pull-right"><h4>Verify by: ______________________</h4></div>
<div class="clearfix"></div>



<?php
$id=$_GET['id'];

mysql_connect("localhost", "crm", "password") or die(mysql_error());
mysql_select_db("mycasl_db") or die(mysql_error());
$array=array();
?>

<?php
// Client1 info array
$sql="SELECT * FROM crm_contact WHERE crm_contact.app_id =".$id;
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
foreach ($row as $key=>$value){
	$array['client1'][$key]=$value;
}

// App Info array
$sql="SELECT * FROM crm_application WHERE crm_application.app_id =".$id;
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
foreach ($row as $key=>$value){
	$array['app'][$key]=$value;
}
// App Info END
?>

<table id="header-table">
  <tr>
    <td width="55%"><h3><?php echo '<strong>'.$array['client1']['FirstName'].'</strong> '.$array['client1']['SurName']; ?></h3></td>
    <td width="15%"><strong>AppID</strong>: <?php echo $array['app']['app_id']; ?></td>
    <td width="15%"><strong>Date</strong>: <?php echo $array['app']['CreatedDate']; ?></td>
    <td width="15%"><strong>Time</strong>: <?php echo $array['app']['CreatedTime']; ?></td>
  </tr>
</table>

<h3>Assumtion:</h3>
<p>1. Minimum documents has been received</p>
<table style="background-color:#ffff00">
  <tr>
    <td width="33%"><strong>Desired Amount</strong></td>
    <td><?php echo $array['app']['DesiredAmount']; ?></td>
  </tr>
</table>

<h3>Personal Details</h3>
<?php
$sql="SELECT * FROM crm_contact WHERE crm_contact.app_id =".$id;
$result = mysql_query($sql) or die(mysql_error());
$num_clients = mysql_num_rows($result);
$num_columns = MYSQL_NUM_FIELDS($result);
FOR($i=0; $i<$num_columns; $i++)// put col name into array
{
	$col = MYSQL_FETCH_FIELD($result);
	$array[0][]=$col->name;
}

$i=1;
WHILE($row = MYSQL_FETCH_ROW($result))// put client fields into array
{
	FOREACH($row AS $cell)
		$array[$i][]=$cell;
	$i++;
}

echo "<table class='client-table'>";
FOR($i=0; $i<$num_columns; $i++){
	$col=$array[0][$i];
	$app1=$array[1][$i];
	$app2=$array[2][$i];
	echo "<tr><td><strong>".$col."</strong></td> <td>".$app1."</td> <td>".$app2."</td> </tr>";
}
echo "</table>";
// Client Info END

echo "
<table>
  <tr>
    <td><strong>Purpose of Loan</strong></td>
    <td>".$array['app']['loanpurposereason']."</td>
  </tr>
  <tr>
    <td><strong>Purpose Details</strong></td>
    <td>".$array['app']['purposedetail']."</td>
  </tr>
</table>
";
?>

<h3>Liabilities</h3>
<?php
$sql="SELECT * FROM crm_liabilities WHERE crm_liabilities.app_id =".$id;
$result = mysql_query($sql) or die(mysql_error());
echo "<table class='liability-table'><tr>";
$fields_num = MYSQL_NUM_FIELDS($result);
FOR($i=0; $i<$fields_num; $i++)
{
	$field = MYSQL_FETCH_FIELD($result);
	ECHO "<td>{$field->name}</td>";
}echo "</tr>";
WHILE($row = mysql_fetch_assoc($result))
{
	ECHO "<tr>";
	FOREACH($row AS $key=>$cell)
		echo "<td>".$cell."</td>";
	ECHO "</tr>";
}
echo "</table>";
// Liability Info END
?>

<h3>Bank Statement Factors (Not considered by iDecision)</h3>
<table style="background-color:#FFFF00" border="1" cellpadding="0" cellspacing="0" width="100%">
      	  <tbody><tr>
      	    <td>
            <p class="doc"><img src="http://www.mycashfinance.com.au/email/Box.png" style="float:left">&nbsp;Gambling activitiew (The Star, TAB,etc)</p>
   	        <p class="doc"><img src="http://www.mycashfinance.com.au/email/Box.png" style="float:left">&nbsp;3 or more dishonours</p>
   	        <p class="doc">Refer to supervisor for review</p></td>
      	    <td>
            <p class="doc"><img src="http://www.mycashfinance.com.au/email/Box.png" style="float:left">&nbsp;Gambling activitiew (The Star, TAB,etc)</p>
            <p class="doc"><img src="http://www.mycashfinance.com.au/email/Box.png" style="float:left">&nbsp;3 or more dishonours</p>
   	        <p class="doc">Refer to supervisor for review</p></td>

    </tr>
</tbody></table>


<h3>Business Details</h3>
<?php
$sql="SELECT * FROM crm_business WHERE crm_business.AppID =".$id;
$result = mysql_query($sql) or die(mysql_error());
WHILE($row = mysql_fetch_assoc($result))
{
	echo "<table class='biz-table'>";
	FOREACH($row AS $key=>$cell)
		echo "<tr><td><strong>".$key."<strong></td><td>".$cell."</td></tr>";
	echo "</table>";
}
// Business Info END
?>

<h3>Asset - <?php echo $array['app']['mc_asset_status'];?>  <img style="float:right" src="http://www.mycashfinance.com.au/email/Box.png"></img></h3>
<?php
$sql="SELECT * FROM crm_vehicle WHERE crm_vehicle.AppID =".$id;
$result = mysql_query($sql) or die(mysql_error());
echo "<table class='vehicle-table'>";
ECHO "<tr>";
/*$fields_num = MYSQL_NUM_FIELDS($result);
FOR($i=0; $i<$fields_num; $i++)
{
	$field = MYSQL_FETCH_FIELD($result);
	ECHO "<td>{$field->name}</td>";
}*/
ECHO '
<td>VehicleID</td>
<td>AppID</td>
<td>Brand</td>
<td>Model</td>
<td>Owner</td>
<td>Finance</td>
<td>Year</td>
<td>Insurance</td>
<td>Value</td>
<td>Owing</td>
<td>Lender</td>
<td>Payment</td>
';
ECHO "</tr>\n";

WHILE($row = MYSQL_FETCH_ROW($result))
{
	
	ECHO "<tr>";

	// $row is array... foreach( .. ) puts every element
	// of $row to $cell variable
	FOREACH($row AS $cell)
	ECHO "<td>$cell</td>";

	ECHO "</tr>\n";
}
echo "</table>";

$sql="SELECT * FROM crm_property WHERE crm_property.AppID =".$id;
$result = mysql_query($sql) or die(mysql_error());
echo "<table class='property-table'><tr>";
$fields_num = MYSQL_NUM_FIELDS($result);
//FOR($i=0; $i<$fields_num; $i++)
//{
//	$field = MYSQL_FETCH_FIELD($result);
//	ECHO "<td>{$field->name}</td>";
//}
ECHO '
<td>PropertyID</td>
<td>AppID</td>
<td>Address</td>
<td>Arrears</td>
<td>Owner</td>
<td>Type</td>
<td>Desc</td>
<td>Land</td>
<td>Bedroom</td>
<td>Bathroom</td>
<td>Owing</td>
<td>Payment</td>
<td>Lender</td>
<td>Value</td>
';
ECHO "</tr>\n";
WHILE($row = MYSQL_FETCH_assoc($result))
{	
	ECHO "<tr>";

	// $row is array... foreach( .. ) puts every element
	// of $row to $cell variable
	FOREACH($row AS $key=>$cell)
	
	ECHO "<td>$cell</td>";

	ECHO "</tr>\n";
}
echo "</table>";

?>

<h3>Credit- <?php echo $array['app']['mc_credit_status'];?> <img style="float:right" src="http://www.mycashfinance.com.au/email/Box.png"></img></h3>
<?php
$sql="SELECT * FROM crm_applicationcredit WHERE crm_applicationcredit.app_id =".$id;
$result = mysql_query($sql) or die(mysql_error());
echo "<table class='credit-table'><tr>";
$fields_num = MYSQL_NUM_FIELDS($result);
FOR($i=0; $i<($fields_num); $i++)
{
	$field = MYSQL_FETCH_FIELD($result);
	ECHO "<td>{$field->name}</td>";
}echo "</tr>";
WHILE($row = mysql_fetch_assoc($result))
{
	ECHO "<tr>";
	FOREACH($row AS $key=>$cell)
		echo "<td>".$cell."</td>";
	ECHO "</tr>";
	
	ECHO '<tr>';
	FOR($i=0; $i<($fields_num); $i++)
	{
		ECHO "<td>&nbsp;</td>";
	}
	ECHO '</tr>';
}
echo "</table>";
// Credit Info END
?>

<h3>Eligible Amount - Reference: iDecision: <?php echo $array['app']['ELA']?></h3>
<table border="1" cellpadding="0" cellspacing="0" width="100%">
  <tbody><tr>
    <td colspan="6" style="border-bottom:0;"><p class="doc">Amount based on Asset $_________________</p></td>
  </tr>
  <tr>
    <td style="border-bottom:0; border-top:0;" width="2%">&nbsp;</td>
    <td width="23%"><p class="doc"><strong>Increase Amount factors</strong></p></td>
    <td width="20%">&nbsp;</td>
    <td width="23%"><p class="doc"><strong>Decrease Amount factors</strong></p></td>
    <td width="20%">&nbsp;</td>
    <td style="border-bottom:0; border-top:0;" width="2%">&nbsp;</td>
  </tr>
  <tr>
    <td style="border-bottom:0; border-top:0;">&nbsp;</td>
    <td><p class="doc">High Income($800+ pw)</p></td>
    <td><p class="doc">+$100&nbsp;&nbsp;<img src="http://www.mycashfinance.com.au/email/Box.png"></p></td>
    <td><p class="doc">Bad credit history</p></td>
    <td><p class="doc">-100&nbsp;&nbsp;<img src="http://www.mycashfinance.com.au/email/Box.png"></p></td>
    <td style="border-bottom:0; border-top:0;">&nbsp;</td>
  </tr>
  <tr>
    <td style="border-bottom:0; border-top:0;">&nbsp;</td>
    <td><p class="doc">High Dispos. Income ($1k p.m.)</p></td>
    <td><p class="doc">+$100&nbsp;&nbsp;<img src="http://www.mycashfinance.com.au/email/Box.png"></p></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td style="border-bottom:0; border-top:0;">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="6" style="border-top:0;" height="24px;"><p class="doc" align="center">Final Amount $_________________ &nbsp;&nbsp;&nbsp;or&nbsp;&nbsp;&nbsp; Financed vehicle rule $1,600&nbsp;&nbsp;<img src="http://www.mycashfinance.com.au/email/Box.png"></p></td>
  </tr>
</tbody></table>
<br><br>












</div><!-- end .container -->




</body>
</html>